﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using SMS.DAL;

namespace SMS.Web.Service
{

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SaleService : ISaleService
    {

        public void DoWork()
        {
            // Add your operation implementation here
            return;
        }


        public Entities.SaleDetail GenerateSaleDetail(string userName, int Product_Stock_ID, out Entities.SMSException serviceError)
        {
            try
            {
                serviceError = null;
                return new StockMasterDA().GenerateSaleDetail(userName, Product_Stock_ID);
            }
            catch (Exception ex)
            {
                serviceError = new Entities.SMSException(ex);
                return null;
            }
        }


        public Entities.SaleHistory SaveSaleHistory(string userName, Entities.SaleHistory saleData, out Entities.SMSException serviceError)
        {
            try
            {
                serviceError = null;
                return new SalesHistoryDA().SaveObject(userName, saleData);
            }
            catch (Exception ex)
            {
                serviceError = new Entities.SMSException(ex);
                return null;
            }
        }


        public decimal GetCustomerBalance(string userName, int customerID, out Entities.SMSException serviceError)
        {
            try
            {
                serviceError = null;
                return new CustomerDA().GetCustomerBalance(userName, customerID);
            }
            catch (Exception ex)
            {
                serviceError = new Entities.SMSException(ex);
                return -0;
            }
        }
    }
}
